package spoon.task;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import spoon.core.domain.Game;
import spoon.service.TenbetService;

@Component
public class TenbetFootballTask {

	@Autowired
	@Qualifier("tenbetFootballService")
	private TenbetService tenbetService;
	
	private List<Game> leagueList = new ArrayList<Game>();
	
	@Scheduled(fixedRateString = "${tenbet.football.delay}")
	public void taskGame() {
		
		if (leagueList.size() == 0) {
			this.leagueList.addAll(tenbetService.getLeagueList());
			return;
		}
		
		tenbetService.getLeague(leagueList.remove(0));
		
	}
}
